package fy.hr.bean;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import fy.util.MyUtil;


public class AwayFormBean {
	private String awaytype;

	private String awayaddress;

	private String applydept;

	private String applydate;

	private String billname;

	private String awaynote;

	private String awayid;

	private String pk_corp;

	private String pk_away_h;

	private String ishrssbill = "N";

	private String isappbill = "Y";

	private String applier;

	private String ts;

	private String dr = "0";

	// private String userCode;

	private String awaybeginday;

	private String awaybegintime = "07:30:00";

	private String awayendday;

	private String awayendtime = "17:30:00";

	private String aheadfee;

	// private String pk_psndoc;

	private String awaysumhour;

	private List<PersonBean> personList;

	private List<String> personCodeList;

	private long summaryId;

	public class PersonBean {

		private String psncode;

		private String pk_tbm_psndoc;

		public String getPsncode() {
			return psncode;
		}

		public void setPsncode(String psncode) {
			this.psncode = psncode;
		}

		public String toString() {
			StringBuilder sb = new StringBuilder();

			Field[] fields = this.getClass().getDeclaredFields();

			if (fields != null) {
				try {
					for (int i = 0, length = fields.length; i < length; i++) {
						sb.append(fields[i].getName()).append(":")
								.append(fields[i].get(this)).append("\n");
					}
				} catch (Exception e) {
					e.printStackTrace();
				}

			}

			return sb.toString();
		}

		public String getPk_tbm_psndoc() {
			return pk_tbm_psndoc;
		}

		public void setPk_tbm_psndoc(String pk_tbm_psndoc) {
			this.pk_tbm_psndoc = pk_tbm_psndoc;
		}
	}

	public void addPersonBean(String pk_tbm_psndoc, String psncode) {
		if (personList == null) {
			personList = new ArrayList<PersonBean>();
		}

		PersonBean pbean = new PersonBean();

		pbean.setPk_tbm_psndoc(pk_tbm_psndoc);
		pbean.setPsncode(psncode);

		personList.add(pbean);
	}

	public String getAheadfee() {
		return aheadfee;
	}

	public void setAheadfee(String aheadfee) {
		this.aheadfee = (aheadfee == null || "".equals(aheadfee)) ? "0"
				: aheadfee;
	}

	public String getApplier() {
		return applier;
	}

	public void setApplier(String applier) {
		this.applier = applier;
	}

	public String getApplydate() {
		return applydate;
	}

	public void setApplydate(String applydate) {
		this.applydate = applydate;
	}

	public String getApplydept() {
		return applydept;
	}

	public void setApplydept(String applydept) {
		this.applydept = applydept;
	}

	public String getAwayaddress() {
		return awayaddress;
	}

	public void setAwayaddress(String awayaddress) {
		this.awayaddress = awayaddress;
	}

	public String getAwaybeginday() {
		return awaybeginday;
	}

	public void setAwaybeginday(String awaybeginday) {
		this.awaybeginday = awaybeginday;
	}

	public String getAwaybegintime() {
		return awaybegintime;
	}

	public void setAwaybegintime(String awaybegintime) {
		this.awaybegintime = awaybegintime;
	}

	public String getAwayendday() {
		return awayendday;
	}

	public void setAwayendday(String awayendday) {
		this.awayendday = awayendday;
	}

	public String getAwayendtime() {
		return awayendtime;
	}

	public void setAwayendtime(String awayendtime) {
		this.awayendtime = awayendtime;
	}

	public String getAwayid() {
		return awayid;
	}

	public void setAwayid(String awayid) {
		this.awayid = awayid;
	}

	public String getAwaynote() {
		return awaynote;
	}

	public void createNewNote() {
		awaynote = new StringBuilder().append(" (No.").append(this.awayid)
				.append(")").append(awaynote).toString();
	}

	public void setAwaynote(String awaynote) {
		this.awaynote = awaynote;
	}

	public String getAwaysumhour() {

		return awaysumhour;
	}

	public void accountAwayDays() {
		this.awaysumhour = String.valueOf(MyUtil.accountDay(this.awaybeginday,
				this.awayendday));
	}

	public String getAwaytype() {
		return awaytype;
	}

	public void setAwaytype(String awaytype) {
		this.awaytype = awaytype;
	}

	public String getBillname() {
		return billname;
	}

	public void setBillname(String billname) {
		this.billname = billname;
	}

	public String getDr() {
		return dr;
	}

	public void setDr(String dr) {
		this.dr = dr;
	}

	public String getIsappbill() {
		return isappbill;
	}

	public void setIsappbill(String isappbill) {
		this.isappbill = isappbill;
	}

	public String getIshrssbill() {
		return ishrssbill;
	}

	public void setIshrssbill(String ishrssbill) {
		this.ishrssbill = ishrssbill;
	}

	public List<PersonBean> getPersonList() {
		return personList;
	}

	public void setPersonList(List<PersonBean> personList) {
		this.personList = personList;
	}

	public String getPk_away_h() {
		return pk_away_h;
	}

	public void setPk_away_h(String pk_away_h) {
		this.pk_away_h = pk_away_h;
	}

	public String getPk_corp() {
		return pk_corp;
	}

	public void setPk_corp(String pk_corp) {
		this.pk_corp = pk_corp;
	}

	// public String getPk_psndoc() {
	// return pk_psndoc;
	// }
	//
	// public void setPk_psndoc(String pk_psndoc) {
	// this.pk_psndoc = pk_psndoc;
	// }

	public String getTs() {
		return ts;
	}

	public void setTs(String ts) {
		this.ts = ts;
	}

/*	public String getUserCode() {
	 return userCode;
	 }
	
	public void setUserCode(String userCode) {
	 this.userCode = userCode;
	 }*/

	public void printFields() {
		StringBuilder sb = new StringBuilder();

		Field[] fields = this.getClass().getDeclaredFields();

		if (fields != null) {
			try {
				for (int i = 0, length = fields.length; i < length; i++) {
					sb.append(fields[i].getName()).append(":")
							.append(fields[i].get(this)).append("\n");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}

		}

		System.out.println(sb.toString());
	}

	public List<String> getPersonCodeList() {
		return this.personCodeList;
	}

	public void setPersonCodeList(List<String> personCodeList) {
		this.personCodeList = personCodeList;
	}

	public long getSummaryId() {
		return summaryId;
	}

	public void setSummaryId(long summaryId) {
		this.summaryId = summaryId;
	}

	public void clear() {
		if (personList != null)
			personList.clear();
		personList = null;

		if (personCodeList != null)

			personCodeList.clear();
		personCodeList = null;
	}
}
